package com.dong.component;

import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;

import java.util.Objects;

/**
 * description
 *
 * @author Administrator 2021/09/02 19:23
 */
public class MyNameGenerator implements BeanNameGenerator {

    @Override
    public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) {
        if (Objects.equals(beanDefinition.getBeanClassName(), MyBean.class.getName())){
            return "public-myBean";
        }
        if (Objects.equals(beanDefinition.getBeanClassName(), MyService.class.getName())){
            return "public-myService";
        }
        if (beanDefinition.getBeanClassName().equals(FactoryMethodComponent.class.getName())){
            return "public-factoryMethodComponent";
        }
        return "public";
    }
}
